home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / osi / isode / vmsisode / vmsgcc139_tar.Z / vmsgcc139_tar / include / stdio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  2.0 KB  |  82 lines

  1. /*
  2.  *    This defines a VAX-11 "C" runtime compatible stdio interface
  3.  */
  4. #ifndef __STDIO_DEFINED
  5. #define __STDIO_DEFINED
  6.  
  7. /*
  8.  *    The maximum number of files we can have open at a time
  9.  */
  10. #define _NFILE 20
  11.  
  12. /*
  13.  *    STDIO buffer size (sure wish it could be 1Kb)
  14.  */
  15. #define BUFSIZ 512
  16.  
  17. /*
  18.  *    This is what the VAX-11 "C" runtime stdio FILE structure looks like
  19.  */
  20. struct    _iobuf     {
  21.     int    _cnt;            /* # of characters in the buffer */
  22.     char    *_ptr;            /* Pointer into the buffer     */
  23.     char    *_base;            /* Pointer to start of buffer     */
  24.     char    _flag;            /* STDIO flags             */
  25. #define    _IOREAD        01            /* Open for reading     */
  26. #define    _IOWRT        02            /* Open for writing     */
  27. #define    _IONBF        04            /* No buffer         */
  28. #define    _IOMYBUF    010            /* Using "my" buffer     */
  29. #define    _IOEOF        020            /* At End Of File     */
  30. #define    _IOERR        040            /* I/O error has occured */
  31. #define    _IOSTRG        0100            /* Doing I/O to a string */
  32. #define    _IORW        0200            /* Open for read/write     */
  33.     char    _file;            /* File descriptor         */
  34.     };
  35.  
  36. /*
  37.  *    Instead of passing around pointers to _iobuf structures, VAX-11 "C"
  38.  *    passes around pointers to pointers.
  39.  */
  40. typedef struct _iobuf *FILE;
  41.  
  42. /*
  43.  *    Also, stdin/stdout/stderr need to be defined
  44.  *    [We also use a hack here that makes the GCC assembler modify
  45.  *     the psect attributes to match those of the VAX-11 "C" runtime]
  46.  */
  47. #define    stdin    $$PsectAttributes_NOSHR$$stdin
  48. #define    stdout    $$PsectAttributes_NOSHR$$stdout
  49. #define    stderr    $$PsectAttributes_NOSHR$$stderr
  50. extern FILE *stdin;
  51. extern FILE *stdout;
  52. extern FILE *stderr;
  53.  
  54. /*
  55.  *    Define NULL and EOF
  56.  */
  57. #define    NULL        0
  58. #define    EOF        (-1)
  59.  
  60. /*
  61.  *    Define the stdio macros
  62.  */
  63. #define getc(p)        fgetc(p)
  64. #define getchar()    fgetc(stdin)
  65. #define putc(x,p)    fputc(x,p)
  66. #define putchar(x)    fputc(x,stdout)
  67. #define feof(p)        (((*p)->_flag&_IOEOF)!=0)
  68. #define ferror(p)    (((*p)->_flag&_IOERR)!=0)
  69. #define fileno(p)    ((*p)->_file)
  70. #define clearerr(p)    ((*p)->_flag &= ~(_IOERR|_IOEOF))
  71.  
  72. /*
  73.  *    Declare stdio routines
  74.  */
  75. FILE    *fopen();
  76. FILE    *fdopen();
  77. FILE    *freopen();
  78. char    *fgets();
  79. long    ftell();
  80.  
  81. #endif    __STDIO_DEFINED
  82.